﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartSpace.Core;

namespace SmartSpace.Data
{
    public interface IDataService
    {
        bool ToTable(EntityMetadata entityMetadata);

        #region metadata
        PagedList<EntityMetadata> FindEntities(int start, int limit);
        EntityMetadata FindEntity(Guid id);
        bool StoreEntity(EntityMetadata metadata);

        bool StoreType(TypeMetadata metadata);
        PagedList<TypeMetadata> FindTypes(int start, int limit);
        TypeMetadata FindType(Guid id);

        bool SaveRelation(EntityMetadata primaryEntity, EntityMetadata relationEntity, bool isInline);
        List<EntityMetadata> FindRelationEntities(Guid entityId);
        EntityMetadata FindPrimaryEntity(Guid entityId);
        #endregion

        #region dictionary
        bool SaveDictionaryType(DictionaryType type);
        List<DictionaryType> FindDictionaryTypes();
        bool SaveDictionaryData(DictionaryData data);
        List<DictionaryData> FindDictionaryDatas(Guid typeId);
        List<DictionaryData> FindDictionaryDatas(DictionaryType type);
        #endregion

        ViewMetadata GetView(Guid entityId);

        DataInstance Store(ViewMetadata view, DataInstance data, User user);

        DataInstance GetData(ViewMetadata view, User user, Guid dataId);

        PagedList<DataInstance> GetListData(ViewMetadata view, int start, int limit);

        //DataInstance Store(User user, DataInstance data, ViewMetadata view);

        //PagedList<DataInstance> GetListData(ViewMetadata view, int start, int limit);

        //DataInstance GetDetailData(ViewMetadata view, Guid id);
    }
}
